package com.yztc.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.yztc.chunboapp.R;

/**
 * Created by My on 2016/10/6.
 */
public class ImageHelper {
    //获取网络加载圆形图片
    public static void getRoundImage(final Context context, String url, final ImageView iv) {
        Glide.with(context).load(url)
                .asBitmap()
                .centerCrop()
                .into(new BitmapImageViewTarget(iv) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        RoundedBitmapDrawable circularBitmapDrawable =
                                RoundedBitmapDrawableFactory.create(context.getResources(),resource);
                        circularBitmapDrawable.setCircular(true);
                        iv.setImageDrawable(circularBitmapDrawable);
                    }
                });
    }

       //获取网络加载常规图片
        public static void getNormalImage(Context context,String url,ImageView iv){
            Glide.with(context)
                    .load(url)
                    .placeholder(R.mipmap.mo_ren_class_5_4)
                    .into(iv);
    }

}
